import { filterNullFields } from '@/utils/fomatter';
import httpService from '../httpService';

/**
 * 根据用户地址同步实名信息
 * @returns 
 */
function walletPersonCerti() {
    return httpService.get(`/wallet/sync/person_certi`)
}


/**
 * 检查钱包所绑定的信息是否完整
 * @returns 
 */
function checkWalletBindContent() {
    return httpService.get(`/wallet/check/bind_content`)
}


/**
 * 查看授权记录
 * @param authorize_status 1-待授权，2-通过，3-超时
 * @returns 
 */
function queryWalletUserAuthorize(authorize_status, offset = 0) {
    var params = {
        'authorize_status': authorize_status, 'limit': 20,
        'offset': offset,
    }
    var filteredParams = filterNullFields(params)
    return httpService.get(`/wallet/query/user_authorize`, filteredParams)
}


/**
 * 查看数据使用流水
 * @param authorize_status 
 * @returns 
 */
function queryWalletUserFlow(type?, offset = 0) {
    var params = {
        'type': type, 
        'limit': 20,
        'offset': offset,
    }
    var filteredParams = filterNullFields(params)
    return httpService.get(`/wallet/query/user_usage_flow`, filteredParams)
}


/**
 * 处理获取数据权限的申请
 * @param auth_id 
 * @param authorize_status 
 * @returns 
 */
function dealWalletUseAuthorize(auth_id, authorize_status) {
    var params = {
        'auth_id': auth_id, 
        'authorize_status': authorize_status,
    }
    return httpService.post(`/wallet/deal/user_authorize`, params)
}


/**
 * 取消使用授权
 * @param auth_id 
 * @returns 
 */
function cancelWalletUseAuthorize(auth_id) {
    var params = {
        'auth_id': auth_id, 
    }
    return httpService.post(`/wallet/cancel/user_authorize`, params)
}

export {
    walletPersonCerti,
    queryWalletUserAuthorize,
    queryWalletUserFlow,
    dealWalletUseAuthorize,
    cancelWalletUseAuthorize,
    checkWalletBindContent,
}

